Page({
  data: {
    totalQuestions: 0,   // 总做题数
    correctQuestions: 0, // 答对的题数
    accuracyRate: 0      // 正确率（百分比）
  },

  onLoad() {
    const history = wx.getStorageSync('practiceHistory') || [];

    const total = history.length;
    const correct = history.filter(item => item.isRight).length;
    const accuracy = total ? ((correct / total) * 100).toFixed(1) : 0;

    this.setData({
      totalQuestions: total,
      correctQuestions: correct,
      accuracyRate: accuracy
    });
  }
});
